package com.yjha.huazhubusiness.utils;

import lombok.extern.slf4j.Slf4j;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

/*
 * @author :
 * @date   :2023/8/30 18:04
 * @description : JAVA
 */
@Slf4j
public class SendGetUilt {
    public static String sendGetjssk(String url, String charset, int timeout)
    {
        String result = "";
        try
        {
            URL u = new URL(url);
            //log.info("获取URL[{}]",u);
            try
            {
                URLConnection conn = u.openConnection();
                conn.connect();
                conn.setConnectTimeout(timeout);
                BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), charset));
                String line="";
                while ((line = in.readLine()) != null)
                {
                        //log.info("line的值[{}]",line);
                    result = result + line;
                }
                //log.info("获取result的值[{}]",result);
                in.close();
            } catch (IOException e) {
                return result;
            }
        }
        catch (Exception e)
        {
            return result;
        }
        return result;
    }
}
